<?php
namespace Src;
//容器概念
class Bean
{

    public static array $objects = [];//存放对象

    private function __construct() {}
     
    private function __clone() {}

    public static function get($alias)
    {
        if (isset(self::$objects[$alias])) {
            return self::$objects[$alias];
        } else {
            return false;
        }
    }

    public static function set($alias, $object)
    {
        self::$objects[$alias] = $object;
    }

    public static function destroy($alias)
    {
        unset(self::$objects[$alias]);
    }

    public static function getall(): array
    {
        return self::$objects;
    }

    public static function setup()
    {
        Self::set('pdo', new Pdo());//mysql 对象
        Self::set('redis', new Redis());// redis对象
        Self::set('logger', new Logger());// log日志对象
        Self::set('response', new Response());// 以json串返回的对象
        Self::set('smarty', new Smarty());// 以json串返回的对象
    }
      
    public function __destruct(){}
 
}